package com.yyq.gxdc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyq.gxdc.entity.OrderInfo;
import com.yyq.gxdc.mapper.OrderInfoMapper;
import com.yyq.gxdc.service.IOrderInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService {
    @Resource
    private OrderInfoMapper orderInfoMapper;

    @Override
    public PageInfo<OrderInfo> findPage(OrderInfo conditioin, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> {
            orderInfoMapper.find(conditioin);
        });
    }
    @Override
    public int add(OrderInfo orderInfo) {
        return orderInfoMapper.insert(orderInfo);
    }
    @Override
    public OrderInfo findById(Integer id) {
        return orderInfoMapper.findById(id);
    }

    @Override
    public OrderInfo getDetailByRid(Integer rid){
        OrderInfo orderInfo = orderInfoMapper.findById(rid);

        return orderInfo;
    }

    @Override
    public int update(OrderInfo orderInfo) {
        return orderInfoMapper.updateById(orderInfo);
    }
    @Override
    public int delete(Integer id) {
        return orderInfoMapper.deleteById(id);
    }

    @Override
    public IPage<OrderInfo> getAllOrderInfo(Page<OrderInfo> page, OrderInfo conditioin){
        return orderInfoMapper.getAllOrderInfo(page,conditioin);
    }
}

